<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>走进汕头 - 汕头特产</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="css/specialty.css">
    <link rel="stylesheet" href="css/style.css">
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top">
        <div class="container">
            <a class="navbar-brand d-flex align-items-center" href="index.html">
                <img src="img/logo.png" alt="走进汕头" class="navbar-logo">
                <span class="brand-text">走進汕頭</span>
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="index.html"><i class="bi bi-house-door"></i> 首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="food.html"><i class="bi bi-egg-fried"></i> 汕头美食</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="specialty.html"><i class="bi bi-shop"></i> 汕头特产</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="scenery.html"><i class="bi bi-image"></i> 汕头美景</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="history.html"><i class="bi bi-book"></i> 汕头历史</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="travel.html"><i class="bi bi-map"></i> 旅游专区</a>
                    </li>
                </ul>
                <form class="d-flex search-form">
                    <input class="form-control me-2" type="search" placeholder="搜索汕头..." id="searchInput">
                    <button class="btn btn-outline-light" type="submit"><i class="bi bi-search"></i></button>
                </form>
                <button class="btn btn-outline-light ms-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#shoppingCart">
                    <i class="bi bi-cart3"></i>
                    <span class="badge bg-danger" id="cartCount">0</span>
                </button>
            </div>
        </div>
    </nav>

    <!-- 特产轮播图 -->
    <div id="specialtyCarousel" class="carousel slide" data-bs-ride="carousel">
        <div class="carousel-indicators">
            <button type="button" data-bs-target="#specialtyCarousel" data-bs-slide-to="0" class="active"></button>
            <button type="button" data-bs-target="#specialtyCarousel" data-bs-slide-to="1"></button>
            <button type="button" data-bs-target="#specialtyCarousel" data-bs-slide-to="2"></button>
        </div>
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img src="img/bg.jpg" class="d-block w-100" alt="潮汕特产">
                <div class="carousel-caption">
                    <h3>潮汕特产</h3>
                    <p>把汕头的美味带回家</p>
                </div>
            </div>
            <div class="carousel-item">
                <img src="img/bg.jpg" class="d-block w-100" alt="手信礼盒">
                <div class="carousel-caption">
                    <h3>手信礼盒</h3>
                    <p>精选潮汕特色，送礼佳品</p>
                </div>
            </div>
            <div class="carousel-item">
                <img src="img/bg.jpg" class="d-block w-100" alt="传统工艺">
                <div class="carousel-caption">
                    <h3>传统工艺</h3>
                    <p>传承百年的潮汕手工艺</p>
                </div>
            </div>
        </div>
        <button class="carousel-control-prev" type="button" data-bs-target="#specialtyCarousel" data-bs-slide="prev">
            <span class="carousel-control-prev-icon"></span>
        </button>
        <button class="carousel-control-next" type="button" data-bs-target="#specialtyCarousel" data-bs-slide="next">
            <span class="carousel-control-next-icon"></span>
        </button>
    </div>

    <!-- 特产分类 -->
    <section class="container mt-5">
        <h2 class="text-center mb-4"><i class="bi bi-tags"></i> 特产分类</h2>
        <div class="row">
            <div class="col-md-3 mb-4">
                <div class="card h-100 specialty-category">
                    <img src="img/bg.jpg" class="card-img-top" alt="食品类">
                    <div class="card-body text-center">
                        <h5 class="card-title">食品类</h5>
                        <p class="card-text">牛肉丸、潮汕粿品、橄榄菜等</p>
                        <a href="#food-section" class="stretched-link"></a>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 specialty-category">
                    <img src="img/bg.jpg" class="card-img-top" alt="茶叶类">
                    <div class="card-body text-center">
                        <h5 class="card-title">茶叶类</h5>
                        <p class="card-text">凤凰单丛、岭头白叶等</p>
                        <a href="#tea-section" class="stretched-link"></a>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 specialty-category">
                    <img src="img/bg.jpg" class="card-img-top" alt="工艺品类">
                    <div class="card-body text-center">
                        <h5 class="card-title">工艺品类</h5>
                        <p class="card-text">潮绣、木雕、陶瓷等</p>
                        <a href="#craft-section" class="stretched-link"></a>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 specialty-category">
                    <img src="img/bg.jpg" class="card-img-top" alt="海产品">
                    <div class="card-body text-center">
                        <h5 class="card-title">海产品</h5>
                        <p class="card-text">鱼丸、鱼饺、干贝等</p>
                        <a href="#seafood-section" class="stretched-link"></a>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 食品类特产 -->
    <section class="container mt-5" id="food-section">
        <h3 class="mb-4"><i class="bi bi-egg-fried"></i> 食品类特产</h3>
        <div class="row">
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="潮汕牛肉丸">
                    <div class="card-body">
                        <h5 class="card-title">潮汕牛肉丸</h5>
                        <p class="card-text text-muted small">500g/袋</p>
                        <p class="card-text">精选优质黄牛肉，手工捶打制作，真空包装，保持新鲜。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥58.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="1" data-name="潮汕牛肉丸" data-price="58.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="潮汕粿品礼盒">
                    <div class="card-body">
                        <h5 class="card-title">潮汕粿品礼盒</h5>
                        <p class="card-text text-muted small">12个装</p>
                        <p class="card-text">传统潮汕粿品组合，包含红桃粿、鼠曲粿等多种口味。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥88.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="2" data-name="潮汕粿品礼盒" data-price="88.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="潮汕橄榄菜">
                    <div class="card-body">
                        <h5 class="card-title">潮汕橄榄菜</h5>
                        <p class="card-text text-muted small">250g/瓶</p>
                        <p class="card-text">传统腌制工艺，咸香可口，下饭佳品。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥28.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="3" data-name="潮汕橄榄菜" data-price="28.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="潮汕沙茶酱">
                    <div class="card-body">
                        <h5 class="card-title">潮汕沙茶酱</h5>
                        <p class="card-text text-muted small">200g/瓶</p>
                        <p class="card-text">潮汕特色调味料，香气浓郁，火锅蘸料必备。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥32.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="4" data-name="潮汕沙茶酱" data-price="32.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 茶叶类特产 -->
    <section class="container mt-5" id="tea-section">
        <h3 class="mb-4"><i class="bi bi-cup-hot"></i> 茶叶类特产</h3>
        <div class="row">
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="凤凰单丛茶">
                    <div class="card-body">
                        <h5 class="card-title">凤凰单丛茶</h5>
                        <p class="card-muted small">250g精装</p>
                        <p class="card-text">潮汕特产茶叶，香气浓郁，回甘持久。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥128.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="5" data-name="凤凰单丛茶" data-price="128.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="岭头白叶">
                    <div class="card-body">
                        <h5 class="card-title">岭头白叶</h5>
                        <p class="card-text text-muted small">200g礼盒</p>
                        <p class="card-text">潮汕特色茶叶，清香怡人，茶汤清澈。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥98.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="6" data-name="岭头白叶" data-price="98.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="蜜兰香单丛">
                    <div class="card-body">
                        <h5 class="card-title">蜜兰香单丛</h5>
                        <p class="card-text text-muted small">150g罐装</p>
                        <p class="card-text">带有天然蜜香的高山单丛茶，口感醇厚。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥158.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="7" data-name="蜜兰香单丛" data-price="158.00" data-img-tea3.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card h-100 product-card">
                    <img src="img/bg.jpg" class="card-img-top" alt="潮汕功夫茶具">
                    <div class="card-body">
                        <h5 class="card-title">潮汕功夫茶具</h5>
                        <p class="card-text text-muted small">一套4件</p>
                        <p class="card-text">传统潮汕功夫茶具，包含茶壶、茶杯等。</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="price fw-bold">¥198.00</span>
                            <button class="btn btn-sm btn-primary add-to-cart" data-id="8" data-name="潮汕功夫茶具" data-price="198.00" data-img="bg.jpg">
                                <i class="bi bi-cart-plus"></i> 加入
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 购物车侧边栏 -->
    <div class="offcanvas offcanvas-end" tabindex="-1" id="shoppingCart" aria-labelledby="shoppingCartLabel">
        <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="shoppingCartLabel"><i class="bi bi-cart3"></i> 我的购物车</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="offcanvas-body">
            <div id="cartItems">
                <!-- 购物车商品将在这里动态生成 -->
                <div class="text-center text-muted py-4">购物车是空的</div>
            </div>
            <div class="cart-summary mt-3 border-top pt-3">
                <div class="d-flex justify-content-between mb-2">
                    <span>商品总数:</span>
                    <span id="cartTotalItems">0件</span>
                </div>
                <div class="d-flex justify-content-between mb-3">
                    <span>总金额:</span>
                    <span id="cartTotalPrice" class="fw-bold">¥0.00</span>
                </div>
                <button class="btn btn-primary w-100" id="checkoutBtn">去结算</button>
            </div>
        </div>
    </div>

    <!-- 结算地址模态框 -->
    <div class="modal fade" id="checkoutModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">确认收货地址</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <!-- 地址列表 -->
                    <div class="address-list mb-3">
                        <h6 class="mb-3">已保存的地址</h6>
                        <div id="savedAddresses">
                            <!-- 地址将通过 JavaScript 动态添加 -->
                        </div>
                    </div>

                    <!-- 添加新地址按钮 -->
                    <button class="btn btn-outline-primary mb-3" id="showAddAddressForm">
                        <i class="bi bi-plus-circle"></i> 添加新地址
                    </button>

                    <!-- 新增地址表单 -->
                    <div id="addAddressForm" class="border rounded p-3 mb-3" style="display: none;">
                        <h6 class="mb-3">新增收货地址</h6>
                        <form id="addressForm">
                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label class="form-label">收货人姓名</label>
                                    <input type="text" class="form-control" name="name" required>
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">手机号码</label>
                                    <input type="tel" class="form-control" name="phone" required>
                                </div>
                                <div class="col-md-12">
                                    <label class="form-label">省市区</label>
                                    <div class="row">
                                        <div class="col">
                                            <select class="form-select" name="province" required>
                                                <option value="">选择省份</option>
                                                <option value="广东省">广东省</option>
                                                <!-- 其他省份 -->
                                            </select>
                                        </div>
                                        <div class="col">
                                            <select class="form-select" name="city" required>
                                                <option value="">选择城市</option>
                                                <option value="汕头市">汕头市</option>
                                                <!-- 其他城市 -->
                                            </select>
                                        </div>
                                        <div class="col">
                                            <select class="form-select" name="district" required>
                                                <option value="">选择区县</option>
                                                <option value="金平区">金平区</option>
                                                <!-- 其他区县 -->
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">详细地址</label>
                                    <textarea class="form-control" name="address" rows="2" required></textarea>
                                </div>
                                <div class="col-12">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="isDefault" id="setDefault">
                                        <label class="form-check-label" for="setDefault">
                                            设为默认地址
                                        </label>
                                    </div>
                                </div>
                                <div class="col-12">
                                    <button type="submit" class="btn btn-primary">保存地址</button>
                                    <button type="button" class="btn btn-outline-secondary" id="cancelAddAddress">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <!-- 订单金额信息 -->
                    <div class="border-top pt-3 mt-3">
                        <div class="d-flex justify-content-between mb-2">
                            <span>商品总额：</span>
                            <span id="modalTotalPrice" class="fw-bold">¥0.00</span>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">返回购物车</button>
                    <button type="button" class="btn btn-primary" id="submitOrder">提交订单</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="bg-dark text-white py-4 mt-5">
        <div class="container">
            <div class="row">
                <div class="col4 mb-3">
                    <h5>关于我们</h5>
                    <p>"走进汕头"网站致力于推广汕头文化、美食和旅游，让更多人了解这座美丽的滨海城市。</p>
                </div>
                <div class="col-md-4 mb-3">
                    <h5>快速链接</h5>
                    <ul class="list-unstyled">
                        <li><a href="index.html" class="text-white">首页</a></li>
                        <li><a href="food.html" class="text-white">汕头美食</a></li>
                        <li><a href="specialty.html" class="text-white">汕头特产</a></li>
li><a href="scenery.html" class="text-white">汕头美景</a></li>
                    </ul>
                </div>
                <div class="col-md-4 mb-3">
                    <h5>联系我们</h5>
                    <p><i class="bi bi-envelope"></i> contact@zoujinshantou.com</p>
                    <p><i class="bi bi-telephone"></i> 0754-12345678</p>
                    <div class="social-icons <a href="#" class="text-white me-2"><i class="bi bi-wechat"></i></a>
                        <a href="#" class="text-white me-2"><i class="bi bi-weibo"></i></a>
                        <a href="#" class="text-white me-2"><i class="bi bi-facebook"></i></a>
                        <a href="#" class="text-white"><i class="bi bi-instagram"></i></a>
                    </div>
                </div>
            </div>
            <hr>
            <div class="text-center">
                <p class="mb-0">&copy; 2025 走进汕头 版权所有</p>
            </div>
        </div>
    </footer>

    <!-- Toast 容器 -->
    <div class="toast-container position-fixed bottom-0 end-0 p-3"></div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="js/script.js"></script>
    <script src="js/specialty.js"></script>
    <script src="js/cart.js"></script>
    <script src="js/checkout.js"></script>
    <script>
    // 在文档加载完成后执行
    $(document).ready(function() {
        // 初始化结算模态框
        const checkoutModal = new bootstrap.Modal(document.getElementById('checkoutModal'));
        
        // 为结算按钮添加点击事件监听器
        $('#checkoutBtn').on('click', function() {
            // 显示结算模态框
            checkoutModal.show();
            
            // 更新模态框中的总价
            const totalPrice = $('#cartTotalPrice').text();
            $('#modalTotalPrice').text(totalPrice);
            
            // 加载已保存的地址
            loadSavedAddresses();
        });
        
        // 加载已保存的地址函数
        function loadSavedAddresses() {
            // 这里可以从 localStorage 或后端 API 获取已保存的地址
            const savedAddresses = JSON.parse(localStorage.getItem('savedAddresses')) || [];
            const addressesContainer = $('#savedAddresses');
            addressesContainer.empty();
            
            if (savedAddresses.length === 0) {
                addressesContainer.html('<p class="text-muted">暂无保存的地址</p>');
            } else {
                savedAddresses.forEach((address, index) => {
                    addressesContainer.append(`
                        <div class="card mb-2">
                            <div class="card-body">
                                <div class="form-check">
                                    <input class="form-check-input" type="radio" name="deliveryAddress" 
                                        id="address${index}" value="${index}" ${address.isDefault ? 'checked' : ''}>
                                    <label class="form-check-label" for="address${index}">
                                        <strong>${address.name}</strong> ${address.phone}<br>
                                        ${address.province}${address.city}${address.district}${address.address}
                                    </label>
                                </div>
                            </div>
                        </div>
                    `);
                });
            }
        }
    });
    </script>
</body>
</html>